﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>SoundGetVolume - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The SoundGetVolume function retrieves a volume setting of a sound device." />
<meta name="ahk:equiv-v1" content="lib/SoundGet.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SoundGetVolume</h1>

<p>检索声音设备的音量设置.</p>

<pre class="Syntax">Setting := <span class="func">SoundGetVolume</span>(<span class="optional">Component, Device</span>)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>Component</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>或<a href="../Concepts.htm#numbers">整数</a></p>
    <p>如果为空或省略, 则检索主音量设置. 否则, 指定组件的显示名称和/或索引. 例如, <code>1</code>, <code>"Line in"</code> 或 <code>"Line in:2"</code>.</p>
    <p>有关详情, 请参阅 <a href="Sound.htm#component">Component (Sound 函数)</a>.</p>
  </dd>

  <dt>Device</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a>或<a href="../Concepts.htm#numbers">整数</a></p>
    <p>如果为空或省略, 则它默认为系统的默认回放设备(不一定是设备 1). 否则, 指定设备的显示名称和/或索引. 例如, <code>1</code>, <code>"Speakers"</code>, <code>"Speakers:2"</code> 或 <code>"Speakers (Example HD Audio)"</code>.</p>
    <p>有关详情, 请参阅 <a href="Sound.htm#device">Device (Sound 函数)</a>.</p>
  </dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#numbers">浮点数</a></p>
<p>函数返回 0.0 到 100.0 之间的浮点数.</p>

<h2 id="Error_Handling">错误处理</h2>
<p>如果无法找到设备或组件, 或组件不支持此控制类型, 则抛出 <a href="Error.htm#TargetError">TargetError</a>. 否则失败时, 抛出 <a href="Error.htm#OSError">OSError</a>.</p>

<h2 id="Remarks">备注</h2>
<p>要发现系统上安装的声音设备的功能 -- 比如名称和可用的组件 -- 请运行这个<a href="Sound.htm#ExSoundcard">声卡分析脚本</a>.</p>

<h2 id="Related">相关</h2>
<p><a href="Sound.htm">Sound 函数</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExMasterVol">
<p><a class="ex_number" href="#ExMasterVol"></a> 检索并报告主音量.</p>
<pre>master_volume := SoundGetVolume()
MsgBox "Master volume is " master_volume " percent."</pre>
</div>

<div class="ex" id="ExMicListenVol">
<p><a class="ex_number" href="#ExMicListenVol"></a> 检索和报告麦克风播放音量.</p>
<pre>mic_volume := SoundGetVolume("Microphone")
MsgBox "Microphone listening volume is " mic_volume " percent."</pre>
</div>

<div class="ex" id="ExMicRecordVol">
<p><a class="ex_number" href="#ExMicRecordVol"></a> 检索并报告麦克风的录音音量.</p>
<pre>mic_volume := SoundGetVolume( , "Microphone")
MsgBox "Microphone recording volume is " mic_volume " percent."</pre>
</div>

</body>
</html>